
<meta charset="utf-8">
<script>
    var num1 = parseInt(prompt("请输入第一个数："));
    var num2 = prompt("请输入运算符：1.+ 2.- 3.* 4./");
    var num3 = parseInt(prompt("请输入第二个数："));

    if(num2==1){
        alert(num1+"+"+num3+"="+(num1+num3));
    }else if(num2==2){
        alert(num1+"-"+num3+"="+(num1-num3));
    }else if(num2==3){
        alert(num1+"*"+num3+"="+(num1*num3));
    }else if(num2==4){
        if(num3==0){
            alert("除数不能为零！")
        }else{
            alert(num1+"/"+num3+"="+(num1/num3));
        }      
    }else{
        alert("错误的运算符！")
    }
</script>